package com.sinosoft.sinopay.web.util;

import com.cfwx.multichannel.constant.StatusConstant;
import com.cfwx.multichannel.http.HttpClient;
import com.cfwx.multichannel.userinterface.pack.HttpPack;
import com.cfwx.multichannel.userinterface.pack.Message;
import com.sinosoft.sinopay.web.gateway.config.ENUM_SMS_CONFIG;
import com.sinosoft.sinopay.web.gateway.dto.SmsSendInfo;

public class HttpSmsUtil {
	/**客户端发送对象*/
	static HttpClient client = new ClientHttp(ENUM_SMS_CONFIG.URL.password());
	public static Boolean sendSms(SmsSendInfo smsSendInfo) {
		Boolean flag=false;
    	HttpPack httpPack = new HttpPack();
		Message packInfo = new Message();
		//用户配置
		packInfo.userName =smsSendInfo.getType().username(); 
		packInfo.passWd=smsSendInfo.getType().password();
		//短信参数
		packInfo.mobile = smsSendInfo.getMobile();
		packInfo.content = smsSendInfo.getContent();
		packInfo.mobileNum = 1;
		packInfo.tunnelFlowId = 1;
		packInfo.tunnelChannelType = "1";
		httpPack.setPackInfo(packInfo);
		// 发送消息
		 client.send(httpPack);
		Integer status= ClientHttp.Status;
		if (status!=null&&StatusConstant.SUCCESS==status) {
			flag=true;
		}else{
		}
		return flag;
	}
 
    public static void main(String[] args) {
    	HttpSmsUtil client = new HttpSmsUtil();
    	String mobiel="18521090988";
    	String content="验证码："+(int)(Math.random()*1000000);
    	ENUM_SMS_CONFIG type=ENUM_SMS_CONFIG.WEBSTITE;
    	System.out.println("用户类型======"+type);
    	SmsSendInfo smsSendInfo=new SmsSendInfo();
    	smsSendInfo.setMobile(mobiel);
    	smsSendInfo.setContent(content);
    	smsSendInfo.setType(type);
    	Boolean flag=client.sendSms(smsSendInfo);
    	if (flag) {
		 System.out.println(true);
		}
    }

}
